<script language="JavaScript" type="text/javascript" src="{$GLOBALS.user_site_url}/system/ext/jquery/jquery.bgiframe.js"></script>
<link type="text/css" href="{$GLOBALS.user_site_url}/system/ext/jquery/css/jquery-ui.css" rel="stylesheet" />
{literal}
<script type="text/javascript">
	$.ui.dialog.prototype.options.bgiframe = true;
	function popUpWindow(url, widthWin, heightWin, title){
		reloadPage = false;
		$("#messageBox").dialog( 'destroy' ).html({/literal}'{capture name="displayJobProgressBar"}<img style="vertical-align: middle;" src="{$GLOBALS.site_url}/system/ext/jquery/progbar.gif" alt="[[Please, wait ...]]" /> [[Please, wait ...]]{/capture}{$smarty.capture.displayJobProgressBar|escape:'quotes'}'{literal});
		$("#messageBox").dialog({
			width: widthWin,
			height: heightWin,
			modal: true,
			title: title
		}).dialog( 'open' );

		$.get(url, function(data){
			$("#messageBox").html(data);
		});

		return false;
		}
</script>
{/literal}
<div class="clr"><br/></div>

<div class="box" id="displayResults">
    <div class="box-header">
        <div class="resultsnumber"><strong>{$emailsCount}</strong> emails</div>
        <div class="pagination">
            {foreach from=$pages item=page}
                {if $page == $currentPage}
                    <strong>{$page}</strong>
                {else}
                    {if $page == $totalPages && $currentPage < $totalPages-3} ... {/if}
                    <a href="?page={$page}{if $sorting_field ne null}&amp;sorting_field={$sorting_field}{/if}{if $sorting_order ne null}&amp;sorting_order={$sorting_order}{/if}&amp;items_per_page={$items_per_page}{$searchFields}">{$page}</a>
                    {if $page == 1 && $currentPage > 4} ... {/if}
                {/if}
            {/foreach}
        </div>
        <div class="numberPerPage">
            per page:
            <select id="items_per_page" name="items_per_page" onchange="window.location = '?restore=1&items_per_page='+this.value;" class="perPage">
                <option value="10" {if $items_per_page == 10}selected="selected"{/if}>10</option>
                <option value="20" {if $items_per_page == 20}selected="selected"{/if}>20</option>
                <option value="50" {if $items_per_page == 50}selected="selected"{/if}>50</option>
                <option value="100" {if $items_per_page == 100}selected="selected"{/if}>100</option>
            </select>
        </div>
    </div>
    <div class="innerpadding">
        <div id="displayResultsTable">
            <table width="100%">
                <thead>
                    <tr>
                        <th>
                            <a href="?restore=1&amp;sorting_field=date&amp;sorting_order={if $sorting_order == 'ASC' && $sorting_field == 'date'}DESC{else}ASC{/if}&amp;items_per_page={$items_per_page}">Date</a>
                        {if $sorting_field == 'date'}{if $sorting_order == 'ASC'}<img src="{image}b_down_arrow.gif" />{else}<img src="{image}b_up_arrow.gif" />{/if}{/if}
                        </th>
                        <th>
                            <a href="?restore=1&amp;sorting_field=subject&amp;sorting_order={if $sorting_order == 'ASC' && $sorting_field == 'subject'}DESC{else}ASC{/if}&amp;items_per_page={$items_per_page}">Subject</a>
                        {if $sorting_field == 'subject'}{if $sorting_order == 'ASC'}<img src="{image}b_down_arrow.gif" />{else}<img src="{image}b_up_arrow.gif" />{/if}{/if}
                        </th>
                        <th>
                            <a href="?restore=1&amp;sorting_field=email&amp;sorting_order={if $sorting_order == 'ASC' && $sorting_field == 'email'}DESC{else}ASC{/if}&amp;items_per_page={$items_per_page}">Email</a>
                        {if $sorting_field == 'email'}{if $sorting_order == 'ASC'}<img src="{image}b_down_arrow.gif" />{else}<img src="{image}b_up_arrow.gif" />{/if}{/if}
                        </th>
                        <th>
                            <a href="?restore=1&amp;sorting_field=username&amp;sorting_order={if $sorting_order == 'ASC' && $sorting_field == 'username'}DESC{else}ASC{/if}&amp;items_per_page={$items_per_page}">Username</a>
                        {if $sorting_field == 'username'}{if $sorting_order == 'ASC'}<img src="{image}b_down_arrow.gif" />{else}<img src="{image}b_up_arrow.gif" />{/if}{/if}
                        </th>
                        <th>
                            <a href="?restore=1&amp;sorting_field=status&amp;sorting_order={if $sorting_order == 'ASC' && $sorting_field == 'status'}DESC{else}ASC{/if}&amp;items_per_page={$items_per_page}">Status</a>
                        {if $sorting_field == 'status'}{if $sorting_order == 'ASC'}<img src="{image}b_down_arrow.gif" />{else}<img src="{image}b_up_arrow.gif" />{/if}{/if}
                        </th>
                    </tr>
                </thead>
                {foreach from=$found_emails item=found_email name=emails_block}
                    <tr id="users[{$found_user.sid}]" class="{cycle values = 'evenrow,oddrow'}">
                        <td>{tr type="date"}{$found_email.date}{/tr}</td>
                        <td><a href="{$GLOBALS.site_url}/email-log/display-message/" onClick="popUpWindow('{$GLOBALS.site_url}/email-log/?action=display_message&sid={$found_email.sid}',600, 600, '[[Viewing Email Message]]'); return false;">{$found_email.subject}</a></td>
                        <td>{$found_email.email}</td>
                        <td>
                            {if $found_email.user.username}
                                {$found_email.user.username}
                                {elseif $found_email.admin.username}
                                {$found_email.admin.username}
                                {if $found_email.admin.sid}
                                    (subadmin)
                                    {else}
                                    (admin)
                                {/if}
                                {else}
                                Undefined
                            {/if}
                        </td>
                        <td>{$found_email.status}</td>
                    </tr>
                {/foreach}
            </table>
        </div>
    </div>
    <div class="box-footer">
        <div class="pagination">
            {foreach from=$pages item=page}
                {if $page == $currentPage}
                    <strong>{$page}</strong>
                {else}
                    {if $page == $totalPages && $currentPage < $totalPages-3} ... {/if}
                    <a href="?page={$page}{if $sorting_field ne null}&amp;sorting_field={$sorting_field}{/if}{if $sorting_order ne null}&amp;sorting_order={$sorting_order}{/if}&amp;items_per_page={$items_per_page}{$searchFields}">{$page}</a>
                    {if $page == 1 && $currentPage > 4} ... {/if}
                {/if}
            {/foreach}
        </div>
    </div>
</div>